"use strict";
require(["static/mobile/js", "jquery.lazyload.min"],
function(i, e) {
    var n = e("#headerSearch"),
    t = e("body");
    if (0 < n.length) {
        e(".js-search").on("click",
        function() {
            n.show(),
            t.css("overflow", "hidden")
        }),
        e(".js-search-off").on("click",
        function() {
            n.hide(),
            t.css("overflow", "inherit")
        }),
        n.on("click", ".key",
        function() {
            var i = n.find("form");
            i.find('input[name="key"]').val(this.innerHTML),
            i.submit()
        });
        var o = n.find(".key-box");
        e.get("//admin.jbcangshu.cn/bk/Search/getHotSearch").done(function(i) {
            if (1 == i.result) {
                var n = "";
                e.each(i.data,
                function(i, e) {
                    n += '<span class="key">' + e + "</span>"
                }),
                o.html(n)
            }
        })
    }
    var a = e("#jNav");
    if (0 < a.length) {
        var r = function() {
            var i, e = a.find(".nav-wrap"),
            n = e.find("ul"),
            t = n.find(".active");
            t[0] && (i = t.position().left, e.width("100em"), e.width(n.width() + 10), a.scrollLeft(i))
        };
        r(),
        e(window).on("resize", i.throttle(r, 100, 200))
    }
    var l = e("#jSubNav");
    if (0 < l.length) {
        var s = l.find("li"),
        c = s.first();
        s.last().position().top == c.position().top ? l.find(".J-more").hide() : l.on("click", ".J-more",
        function() {
            l.toggleClass("subnav-more")
        });
        l.find(".active").position().top > c.position().top && l.find(".J-more").trigger("click")
    }
    var d = e("img.J_lazyImg"),
    h = (document.documentElement.clientHeight >> 0) / 2 >> 0;
    d.lazyload({
        placeholder: "",
        failure_limit: d.length,
        threshold: h,
        load: function() {
            e(this).removeClass("J_lazyImg").removeAttr("data-original")
        }
    }),
    e(window).trigger("scroll"),
    e(".advert-close").on("click",
    function() {
        e(this).parents(".g-advert").hide()
    });
    var f, g, v;
    e("#gContainer").length && (f = window.screen.height, g = e("#gContainer"), v = e("#gShowBtn"), 1.5 * f < g.height() && (g.addClass("g-hidden").css("maxHeight", 1.5 * f), v.css("display", "block"), v.on("click",
    function() {
        e(this).hide(),
        g.removeClass("g-hidden").removeAttr("style")
    })))
});